﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna;

using AloneLibrary.GameObjects;


namespace AloneLibrary
{
	public static class Physics
	{ 
		private static Vector3 gravity = new Vector3(0.0f, -0.981f, 0.0f);
		
		/// <summary>
		/// Applies the gravity.
		/// </summary>
		/// <param name="gameTime">The game time.</param>
		/// <param name="player">The player.</param>
		public static void ApplyPhysics(GameTime gameTime, DynamicGameObject player, float groundHeight)
		{
			if (player.Position.Y > groundHeight || player.Velocity.Y > 0)
			{
				player.Position.Y += player.Velocity.Y;
				player.Velocity.Y += (gravity.Y * 10) * (float)(gameTime.ElapsedGameTime.Milliseconds / 1000f);
				
			}
			if (player.Position.Y < groundHeight)
			{
				player.Position.Y = groundHeight;
				player.Velocity.Y = 0;
			}
		}
	}
}
